package mvp.com.bbc.newrelyframes.app.uitls;

import android.content.Context;
import android.os.Build;
import android.view.View;

/**
 * 状态栏工具
 * Created by 轻吻旧时光 on 2017/5/20.
 */

public class StatusBarUtil {

    /**
     * 获取状态栏高度
     * */
    public static int getStatusBarHeight(Context context){
        int statusBarHeight = -1;
        //获取status_bar_height资源的ID
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            //根据资源ID获取响应的尺寸值
            statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
        }
        return statusBarHeight;
    }


    /*
    设置顶部导航栏的padding
     */
    public static void setNaviBarPaddingTop(Context context,View view){
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT){
            view.setPadding(0,getStatusBarHeight(context),0,0);
        }
    }
}
